package cn.edu.nju.software.cdiy.action.user.login;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;

import cn.edu.nju.software.cdiy.bean.Uorder;
import cn.edu.nju.software.cdiy.service.UorderService;
import cn.edu.nju.software.cdiy.util.BusinessConstant;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class CancelOrderAction extends ActionSupport implements ServletResponseAware {

	private HttpServletResponse response;
	private UorderService uorderService;
	private Long id;

	public void setUorderService(UorderService uorderService) {
		this.uorderService = uorderService;
	}

	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
		this.response.setCharacterEncoding("UTF-8");
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void cancel() throws Exception {
		Uorder uorder = new Uorder();
		uorder.setId(id);
		uorderService.setState(uorder, BusinessConstant.UORDER_STATE6);
		response.getWriter().write("取消成功！");
	}

}
